/*! lzf */

function oSearchSuggest(p) {
	var r = $(p.input),
		l = $(p.suggestWrap),
		o = "",
		t = !1;
	l.bind("mousedown", function() {
		t = !0
	}).mouseup(function() {
		t = !1
	});
	var a = function() {
			l.hide()
		},
		d = function(t) {
			if("block" == l.css("display") && 38 == t.keyCode || 40 == t.keyCode) {
				var a = l.find("p.hover");
				if(38 == t.keyCode)
					if(0 < a.length) {
						var d = a.removeClass("hover").prev();
						0 < d.length && (d.addClass("hover"), o = d.find(".display-id").text() + " " + d.find(".ppt-name").text() + " " + d.find(".ct-name").text(), r.val(o.trim()).attr("data-id", d.attr("data-id")))
					} else {
						var e = l.find("p:last");
						e.addClass("hover"), o = e.find(".display-id").text() + " " + e.find(".ppt-name").text() + " " + e.find(".ct-name").text(), r.val(o.trim()).attr("data-id", e.attr("data-id"))
					}
				else if(40 == t.keyCode)
					if(0 < a.length) {
						var i = a.removeClass("hover").next();
						0 < i.length && (i.addClass("hover"), o = i.find(".display-id").text() + " " + i.find(".ppt-name").text() + " " + i.find(".ct-name").text(), r.val(o.trim()).attr("data-id", i.attr("data-id")))
					} else {
						var n = l.find("p:first");
						n.addClass("hover"), o = n.find(".display-id").text() + " " + n.find(".ppt-name").text() + " " + n.find(".ct-name").text(), r.val(o.trim()).attr("data-id", n.attr("data-id"))
					}
			} else {
				var s = $.trim(r.val());
				p.func(s), s
			}
		};
	this.dataDisplay = function(t) {
		if(t.length <= 0) return console.log("hello world"), void l.hide();
		var a = "";
		l.html("");
		for(var d = 0; d < t.length; d++) {
			var e = t[d];
			"ppt_drop_handle" == e.ppt_name ? a += '<p class="searchItem ppt_drop_handle" data-id="' + e.apartment_id + '"><span class="ppt-name">' + e.att_title + "</span></p>" : "public_ppt_drop_handle" == e.ppt_name ? a += '<p class="searchItem public_ppt_drop_handle" data-id="' + e.apartment_id + '" data-city="' + e.city_id + '" data-region="' + e.region_id + '" data-area="' + e.area_id + '" data-addr="' + e.ppt_addr + '" data-weights="' + e.ppt_weights + '" data-note="' + e.ppt_note + '" data-sku="' + e.sku_group + '"><span class="ppt-name">' + e.att_title + "</span></p>" : "add_ppt_drop_handle" == e.ppt_name ? a += '<p class="searchItem add_ppt_drop_handle" data-id="' + e.apartment_id + '"><span class="ppt-name">' + e.att_title + '</span><span class="ct-name" style="color: #999; float: right; padding-right: 15px;">娣诲姞</span></p>' : a += '<p class="searchItem" data-id="' + e.apartment_id + '"><span class="display-id">' + e.display_id + '</span><span class="ppt-name">' + e.att_title + '</span><span class="ct-name">' + e.ppt_name + "</span></p>"
		}
		l.html(a), l.show(), l.find("p").hover(function() {
			l.find("p").removeClass("hover"), $(this).addClass("hover")
		}, function() {
			$(this).removeClass("hover")
		}).bind("click", function() {
			$(this).hasClass("user_id_handle") ? (o = $(this).find(".ppt-name").text(), r.val(o.trim()).attr("data-id", $(this).attr("data-id"))) : $(this).hasClass("add_ppt_drop_handle") ? (o = $(this).find(".ppt-name").text(), r.val(o.trim()).attr("data-id", $(this).attr("data-id"))) : (o = $(this).find(".display-id").text() + " " + $(this).find(".ppt-name").text() + " " + $(this).find(".ct-name").text(), r.val(o.trim()).attr("data-id", $(this).attr("data-id")).change()), l.hide()
		})
	}, r.bind("focus keyup", d), r.bind("blur", function() {
		setTimeout(function() {
			0 == t && (r.val(o.trim()), a())
		}, 200)
	})
}